package com.example;

import org.junit.jupiter.api.Test;

import java.util.*;

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();

        for (int i = 0; i < 10; i++) {
            list.add("Item " + i);
        }

        Queue<String> queue = new LinkedList<>(list);
        for (int i = 0; i < 5; i++) {
            System.out.println("list" + i + list.get(i));
            list.remove(list.get(i));
        }

        for (int i = 0; i < 50; i++) {
            System.out.println("queue" + i + queue.poll()); // poll() removes and returns the head of the queue
        }
        System.out.println(queue);

//        list.forEach(p -> {
//            System.out.println("shang" + p);
//            list.remove(p);
//        });
        System.out.println(list);

    }

    @Test
    public void test() {
        Person person = null;
        Person person1 = Optional.ofNullable(person).orElse(new Person("默认"));
        System.out.println(person);
        System.out.println(person1);
    }

    class Person {
        public String name;

        public Person(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    '}';
            }
    }
}